package com.squirrel.michale;

public class Day20240504_LeetCode002712 {

    public long minimumCost(String s) {

        long ans = 0;
        char[] charArray = s.toCharArray();
        int n = charArray.length;
        for (int i = 1; i < n; i++)
            if (charArray[i - 1] != charArray[i])
                ans += Math.min(i, n - i);
        return ans;
    }

}
